var e = getApp(),k = require("../../../host"),h=require("../../../host");

Page({
    data: {
        show: !1,
        dataList: "",
        agreementShow: !1,
        userAgreement: "",
        platformAgreement: "",
        wechat_login_mode: !1,
        popUp: "",
        isShow:true,
        xinShow:true,//昕健康

        fuShow:false
    },
    onLoad: function(e) {
        this.setData({
            popUp: this.selectComponent("#popUp")
        });
        if(h.uniacid == "103"){
            this.setData({
                fuShow:true
            })
        }
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
        let hxtid = wx.getStorageSync('hxtid')
        if(hxtid == '96'){
            this.setData({
                isShow:false
            })
        }

        if(k.uniacid == 102){
            this.setData({
                xinShow:false
            })
        }

    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    confirm: function() {
        this.setData({
            show: !1
        });
    },
    handleGetPhoneNumber:function(t) {
        var a = t.detail;
        "getPhoneNumber:ok" == a.errMsg && this.getPhoneM(a.code);
    },
    getPhoneM: function(t) {
        var a = e.getNetAddresss("member.member.miniMemberMobile"), s = this;
        e._postNetWork({
            url: a,
            showToastIn: !1,
            data: {
                code: t,
                not_validate_page: "0"
            },
            success: function(t) {
                var a = t.data;
                if(1 == a.result){
                    // s.setData({
                    //     "dataList.mobile": a.data.phone_info.purePhoneNumber
                    // }) 
                    s.savePhone(a.data.phone_info.purePhoneNumber)
                }else{
                    wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                }
            },
            fail: function(t) {}
        });
    },
    savePhone(tel){
        var a = e.getNetAddresss("member.member.bindMobile"), s = this;
        e._postNetWork({
            url:a,
            showToastIn: !1,
            data: {
                mobile: tel,
                mini_first_time_bind: 1
            },
            validateBol: 2,
            success: function(e) {
                var n = e.data;
                if(1 == n.result){
                    s.setData({
                        "dataList.mobile": tel
                    }) 
                }else{
                    wx.showToast({
                        icon: "none",
                        title: n.msg,
                        duration: 1500
                    });
                }
            },
        })
    },

    openPopUp: function(e) {
        this.data.popUp.checkShow(), this.data.popUp.stateChanges(e.currentTarget.dataset.celltype);
    },
    getData: function() {
        var a = this, t = this, n = /^(\d{6})\d+(\d{4})$/, o = e.getNetAddresss("member.member-info.user-info-update-page");
        e._getNetWork({
            url: o,
            success: function(o) {
                var s = o.data;
                1 == s.result ? (a.setData({
                    dataList: s.data
                }), e._isTextEmpty(t.data.dataList.bank_card) || a.setData({
                    "dataList.bank_card": t.data.dataList.bank_card.replace(n, "$1******$2")
                }), t.data.popUp.assignment("alipayForm.alipay", s.data.alipay), t.data.popUp.assignment("alipayForm.alipayname", s.data.alipayname), 
                t.data.popUp.assignment("weChatForm.wechat", s.data.wechat)) : wx.showToast({
                    icon: "none",
                    title: s.msg,
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getMemberData: function() {
        var a = this, t = e.getNetAddresss("member.member.member-data");
        e._getNetWork({
            url: t,
            data: {
                v: 2,
                basic_info: 1
            },
            success: function(e) {
                var t = e.data;
                1 == t.result ? a.setData({
                    wechat_login_mode: response.data.setting.wechat_login_mode
                }) : wx.showToast({
                    icon: "none",
                    title: t.msg,
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    bindTel: function() {
        wx.navigateTo({
            url: "/packageA/member/editmobile/editmobile?num=" + this.data.dataList.mobile + "&fromApp=2&editType=1"
        }), wx.setStorage({
            key: "isset",
            data: 1
        });
    },
    agreementContent: function(a) {
        var t = this, n = "";
        this.data.dataList.platform_agreement.status && "platform" == a ? n = "member.member-info.platform-agreement" : this.data.dataList.register_agreement.status && "register" == a && (n = "member.member-info.register-agreement");
        var o = e.getNetAddresss(n);
        e._getNetWork({
            url: o,
            success: function(e) {
                var a = e.data;
                1 == a.result ? t.setData({
                    platformAgreement: a.data,
                    "platformAgreement.content": a.data.content.replace(/\<img/gi, '<img style ="max-width:100%;height:auto"')
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getAgreement: function(e) {
        this.setData({
            agreementShow: !0
        }), this.agreementContent(e.currentTarget.dataset.value);
    },
    closeAgreement: function() {
        this.setData({
            agreementShow: !1
        });
    },
    editBank: function() {
        wx.navigateTo({
            url: "/packageA/member/memberBank/memberBank"
        });
    },
    editBalancePwd: function() {
        var a = e.getNetAddresss("member.balance-password.is-has-password");
        e._getNetWork({
            url: a,
            success: function(e) {
                var a = e.data;
                1 == a.result ? a.data.is_has ? wx.navigateTo({
                    url: "/packageA/member/balance_password/balance_password"
                }) : wx.navigateTo({
                    url: "/packageA/member/set_balance_password/set_balance_password"
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1e3
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    userinfo: function() {
        wx.navigateTo({
            url: "/packageA/member/new_userinfo/new_userinfo"
        });
    },
    convergenceSettlementCard: function() {
        wx.navigateTo({
            url: "/packageA/others/HJinfo/bankCardInformation/bankCardInformation"
        });
    },
    address: function() {
        wx.navigateTo({
            url: "/packageD/member/addressList/addressList"
        });
    },
    memberCancel: function() {
        wx.navigateTo({
            url: "/packageI/member_cancel/member_cancel"
        });
    },
    agreement: function() {
        wx.navigateTo({
            url: "/packageA/member/info/agreement/agreement?type=user"
        });
    },
    onShareAppMessage: function() {}
});